<?php
// +--
// | https://github.com/haojohnny
// | @Author: Johnny
// | Date: 2019-07-04 19:35
// | Remark:
// |

namespace wuwu\cosydevtool\command\make;

use think\console\Input;
use think\console\Output;
use think\console\Input\Argument;
use wuwu\cosydevtool\BaseMake;

class Curd extends BaseMake
{
    protected function configure()
    {
        $this->setName('cosy:curd')
            ->addArgument('name', Argument::REQUIRED, 'Please input your class name')
            ->addArgument('tableName', Argument::REQUIRED, 'Please input your table name')
            ->setDescription('curd创建model,validate和controller');
    }

    public function execute(Input $input, Output $output)
    {
        (new Model())->executeBuild($input, $output);
        

//        $validate = new Validate();
//        $validate->input = $input;
//        $validate->executeBuild($input, $output);
//
//        (new Controller())->executeBuild($input, $output);
    }

    protected function getPathName(string $name): string
    {
        $name = str_replace('app\\', '', $name);

        return $this->app->getBasePath() . ltrim(str_replace('\\', '/', $name), '/') . '.php';
    }
}